using UnityEngine;

public class InAppSubscriptionUI : MonoBehaviour
{
	[SerializeField]
	private UILabel promoTitle;

	[SerializeField]
	private UILabel promoDescription;

	[SerializeField]
	private UILabel goldAmount;

	[SerializeField]
	private UILabel cashAmount;

	private InAppProduct _inAppProduct;

	public InAppProduct inAppProduct
	{
		get
		{
			if (_inAppProduct == null)
			{
				_inAppProduct = GetComponentInParent<InAppProduct>();
			}
			return _inAppProduct;
		}
	}

	private void SetSubscriptionUI()
	{
		InAppSubscriptionsController.InAppPromo promo = InAppSubscriptionsController.instance.Promo;
		InAppSubscriptionsController.SubscriptionParameters promoParameters = InAppSubscriptionsController.instance.PromoParameters;
		if (promo.Enabled)
		{
			promoTitle.text = promo.GetTitle();
			promoDescription.text = promo.GetDescription();
			goldAmount.text = promoParameters.startGold.ToString();
			cashAmount.text = promoParameters.startCash.ToString();
		}
	}

	private void OnEnable()
	{
		SetSubscriptionUI();
		InAppPromoController.promosParsedFromJson += SetSubscriptionUI;
	}

	private void OnDisable()
	{
		InAppPromoController.promosParsedFromJson -= SetSubscriptionUI;
	}
}
